package correct.day16;

import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.next();
        int n = in.nextInt();
        int len = str.length();
        int[] arr = new int[len - n + 1];
        for(int i = 0; i <= len - n; i++) {
            int count = 0;
            for(int j = 0; j < n; j++) {
                if(str.charAt(i+j) == 'C' || str.charAt(i+j) == 'G') {
                    count++;
                }
            }
            arr[i] = count;
        }
        int max = 0;

        for(int i = 0; i <= len - n; i++) {
            max = Math.max(max, arr[i]);
        }
        for(int i = 0; i <= len - n; i++) {
            if(arr[i] == max) {
                for(int j = 0; j < n; j++) {
                    System.out.print(str.charAt(max + j));
                }
                break;
            }
        }
    }
}
